﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Xml;
using System.Xml.Linq;

namespace WDTAsg2
{
    public partial class NavBar : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            // Open xml file navlinks.xml
            var doc = XDocument.Load(Server.MapPath("~/Controls/navlinks.xml"));

            // Linq Xml and grab data from file
            var results = from link in doc.Descendants("Link")
                          select link;

            // Loop through each element and create a hyperlink
            foreach (var link in results)
            {
                HyperLink anch = new HyperLink();
                anch.Text = link.Attribute("title").Value;
                anch.NavigateUrl = link.Attribute("url").Value;
                links.Controls.Add(anch);           
            }
            

        }
    }
}